package cn.fbs.util;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @program: springbootdemo
 * @description: 通用的异常处理器类
 * @author: wxk
 * @create: 2020-12-22 09:10
 **/
@ControllerAdvice
public class CommonExceptionHandler {

    @ExceptionHandler(QbException.class)
    public ResponseEntity<ExceptionResult> handlerException(QbException e){
        return ResponseEntity.status(e.getExceptionEnums().getCode())
                .body(new ExceptionResult(e.getExceptionEnums()));
    }

}
